<template>
  <div class="dashboard">
    <div class="sidebar">
      <div class="logo">后台管理系统</div>
      <nav class="nav">
        <router-link to="/dashboard/user" class="nav-item" active-class="active">
          用户管理
        </router-link>
        <router-link to="/dashboard/worker" class="nav-item" active-class="active">
          维修工管理
        </router-link>
        <router-link to="/dashboard/order" class="nav-item" active-class="active">
          订单管理
        </router-link>
        <router-link to="/dashboard/item" class="nav-item" active-class="active">
          奖品管理
        </router-link>
      </nav>
      <div class="logout" @click="handleLogout">退出登录</div>
    </div>
    <div class="main">
      <router-view></router-view>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'

const router = useRouter()

const handleLogout = () => {
  localStorage.removeItem('token')
  router.push('/login')
}
</script>

<style scoped>
.dashboard {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 200px;
  background-color: #304156;
  color: white;
  display: flex;
  flex-direction: column;
}

.logo {
  height: 60px;
  line-height: 60px;
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  border-bottom: 1px solid #1f2d3d;
}

.nav {
  flex: 1;
  padding: 20px 0;
}

.nav-item {
  display: block;
  padding: 12px 20px;
  color: #bfcbd9;
  text-decoration: none;
  font-size: 14px;
}

.nav-item:hover {
  color: white;
  background-color: #263445;
}

.nav-item.active {
  color: white;
  background-color: #263445;
}

.logout {
  padding: 12px 20px;
  color: #bfcbd9;
  cursor: pointer;
  font-size: 14px;
  border-top: 1px solid #1f2d3d;
}

.logout:hover {
  color: white;
  background-color: #263445;
}

.main {
  flex: 1;
  padding: 20px;
  background-color: #f0f2f5;
  overflow: auto;
}
</style> 